package com.abvnet.project.water.api.web;

import com.abvnet.framework.web.controller.BaseController;
import com.abvnet.framework.web.domain.AjaxResult;
import com.abvnet.project.water.project.domain.ProjectPlan;
import com.abvnet.project.water.project.domain.ProjectPlanApi;
import com.abvnet.project.water.project.domain.ProjectPlanDescription;
import com.abvnet.project.water.project.service.IProjectPlanDescriptionService;
import com.abvnet.project.water.project.service.IProjectPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/project/plan")
public class ApiProjectPlanController extends BaseController {

    @Autowired
    private IProjectPlanService projectPlanService;
    @Autowired
    private IProjectPlanDescriptionService projectPlanDescriptionService;

    @GetMapping("/list")
    public AjaxResult list(@RequestParam("projectId") Long projectId) {
        //return AjaxResult.success(projectPlanService.selectProjectPlanListByProjectId(projectId));
        List<ProjectPlan> projectPlan = projectPlanService.selectProjectPlanListByProjectId(projectId);
        ProjectPlanDescription projectPlanDescription = projectPlanDescriptionService.selectProjectPlanDescriptionByProjectId(projectId);
        ProjectPlanApi projectPlanApi = new ProjectPlanApi();
        projectPlanApi.setProjectPlan(projectPlan);
        projectPlanApi.setProjectPlanDescription(projectPlanDescription);
        return AjaxResult.success(projectPlanApi);
    }
}
